/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('nbftestpop', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model AddRequest {
  x?: int32(name='x'),
  y?: int32(name='y'),
}

model AddResponseBody = {
  sum?: int32(name='sum'),
}

model AddResponse = {
  headers: map[string]string(name='headers'),
  body: AddResponseBody(name='body'),
}

async function add(request: AddRequest): AddResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return addWithOptions(request, headers, runtime);
}

async function addWithOptions(request: AddRequest, headers: map[string]string, runtime: Util.RuntimeOptions): AddResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.x)) {
    query.x = request.x;
  }
  if (!Util.isUnset(request.y)) {
    query.y = request.y;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  return doROARequest('Add', '2021-08-23_16-14-17-275', 'HTTPS', 'GET', 'AK', `/kxNineSixThree/add`, 'json', req, runtime);
}

model HttpGroupTestRequest {
  devConfig?: {
    endPointType?: string(name='endPointType'),
    languages?: [ string ](name='languages'),
  }(name='devConfig'),
  groupId?: string(name='groupId'),
  externalId?: string(name='externalId'),
  id?: string(name='id'),
  version?: string(name='version'),
  extraInfo?: string(name='extraInfo'),
  desc?: string(name='desc'),
}

model HttpGroupTestResponseBody = {
  result?: string(name='result'),
  success?: boolean(name='success'),
  errorCode?: string(name='errorCode'),
  errorMsg?: string(name='errorMsg'),
}

model HttpGroupTestResponse = {
  headers: map[string]string(name='headers'),
  body: HttpGroupTestResponseBody(name='body'),
}

async function httpGroupTest(request: HttpGroupTestRequest): HttpGroupTestResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return httpGroupTestWithOptions(request, headers, runtime);
}

async function httpGroupTestWithOptions(request: HttpGroupTestRequest, headers: map[string]string, runtime: Util.RuntimeOptions): HttpGroupTestResponse {
  Util.validateModel(request);
  var body : map[string]any= {};
  if (!Util.isUnset(request.devConfig)) {
    body.devConfig = request.devConfig;
  }
  if (!Util.isUnset(request.groupId)) {
    body.groupId = request.groupId;
  }
  if (!Util.isUnset(request.externalId)) {
    body.externalId = request.externalId;
  }
  if (!Util.isUnset(request.id)) {
    body.id = request.id;
  }
  if (!Util.isUnset(request.version)) {
    body.version = request.version;
  }
  if (!Util.isUnset(request.extraInfo)) {
    body.extraInfo = request.extraInfo;
  }
  if (!Util.isUnset(request.desc)) {
    body.desc = request.desc;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  return doROARequest('HttpGroupTest', '2021-08-23_16-14-17-275', 'HTTPS', 'POST', 'AK', `/kxHttpTest/httpGroupTest`, 'json', req, runtime);
}

model MultiComplexRequest {
  arg0?: string(name='arg0'),
  arg1?: int32(name='arg1'),
  arg2?: {
    stringValue?: string(name='stringValue'),
    intValue?: int32(name='intValue'),
    booleanValue?: boolean(name='booleanValue'),
    integerValue?: int32(name='integerValue'),
    longValue?: long(name='longValue'),
    secondInput?: {
      secondString?: string(name='secondString'),
      thirdList?: [ 
        {
          thirdInt?: int32(name='thirdInt'),
          thirdString?: string(name='thirdString'),
        }
      ](name='thirdList'),
      secondInt?: int32(name='secondInt'),
    }(name='secondInput'),
  }(name='arg2'),
}

model MultiComplexShrinkRequest {
  arg0?: string(name='arg0'),
  arg1?: int32(name='arg1'),
  arg2Shrink?: string(name='arg2'),
}

model MultiComplexResponseBody = {
  stringValue?: string(name='stringValue'),
  secondOutput?: {
    secondString?: string(name='secondString'),
    thirdList?: [ 
      {
        thirdInt?: int32(name='thirdInt'),
        thirdString?: string(name='thirdString'),
      }
    ](name='thirdList'),
    secondInt?: int32(name='secondInt'),
  }(name='secondOutput'),
  intValue?: int32(name='intValue'),
  booleanValue?: boolean(name='booleanValue'),
  integerValue?: int32(name='integerValue'),
  longValue?: long(name='longValue'),
}

model MultiComplexResponse = {
  headers: map[string]string(name='headers'),
  body: MultiComplexResponseBody(name='body'),
}

async function multiComplex(request: MultiComplexRequest): MultiComplexResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return multiComplexWithOptions(request, headers, runtime);
}

async function multiComplexWithOptions(tmpReq: MultiComplexRequest, headers: map[string]string, runtime: Util.RuntimeOptions): MultiComplexResponse {
  Util.validateModel(tmpReq);
  var request = new MultiComplexShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.arg2)) {
    request.arg2Shrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.arg2, 'arg2', 'json');
  }
  var query : map[string]any= {};
  if (!Util.isUnset(request.arg0)) {
    query.arg0 = request.arg0;
  }
  if (!Util.isUnset(request.arg1)) {
    query.arg1 = request.arg1;
  }
  if (!Util.isUnset(request.arg2Shrink)) {
    query.arg2 = request.arg2Shrink;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  return doROARequest('MultiComplex', '2021-08-23_16-14-17-275', 'HTTPS', 'GET', 'AK', `/kxNineSixThree/multiComplex`, 'json', req, runtime);
}

model GetSiteDomainRequest {
  id?: string(name='id'),
  age?: int32(name='age'),
  hostName?: string(name='hostName'),
  regionType?: string(name='regionType'),
  regionTypeName?: string(name='regionTypeName'),
}

model GetSiteDomainResponseBody = {
  result?: string(name='result'),
  success?: boolean(name='success'),
  errorCode?: string(name='errorCode'),
  errorMsg?: string(name='errorMsg'),
}

model GetSiteDomainResponse = {
  headers: map[string]string(name='headers'),
  body: GetSiteDomainResponseBody(name='body'),
}

async function getSiteDomain(request: GetSiteDomainRequest): GetSiteDomainResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getSiteDomainWithOptions(request, headers, runtime);
}

async function getSiteDomainWithOptions(request: GetSiteDomainRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetSiteDomainResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.id)) {
    query.id = request.id;
  }
  if (!Util.isUnset(request.age)) {
    query.age = request.age;
  }

  var body : map[string]any= {};
  if (!Util.isUnset(request.hostName)) {
    body.hostName = request.hostName;
  }
  if (!Util.isUnset(request.regionType)) {
    body.regionType = request.regionType;
  }
  if (!Util.isUnset(request.regionTypeName)) {
    body.regionTypeName = request.regionTypeName;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  return doROARequest('GetSiteDomain', '2021-08-23_16-14-17-275', 'HTTPS', 'POST', 'AK', `/kxHttpTest/firstHttp`, 'json', req, runtime);
}

